cmake_minimum_required(VERSION 3.27)
project(MyApp)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 添加本目录下的cmake模块路径
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/cmake)

set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)

# set(BUILD_SHARED_LIBS ON)
set(BUILD_EXAMPLE OFF)

#强制使用utf-8编码编译源码和输出目标
if(MSVC)
    add_compile_options(/utf-8)
endif()

#添加子项目
if(NOT EXIST_MYLOG)
    add_subdirectory(pkt/mylog)
endif()

# 此处已经添加了mylog子项目，做此标志是为了防止一个工程内重复添加子项目引发的错误
# 此处为项目约定，并不是语法，只是单纯为了解决项目间重复依赖
# 建议在顶层项目中定义此变量
set(EXIST_MYLOG ON)

#导入模块检测
include(CheckMyLog)

if(NOT EXIST_MYLB)
    add_subdirectory(pkt/mylib)
endif()
set(EXIST_MYLB ON)



#创建可执行程序
add_executable(MyApp main.cpp)
#为目标连接库并添加目标依赖
target_link_libraries(MyApp mylog mylib)
include(Load3rdparty)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "My App")

install(TARGETS ${PROJECT_NAME}
    RUNTIME DESTINATION bin
)
